<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use Think\Controller;

/**
 * 前台公共控制器
 * 为防止多分组Controller名称冲突，公共Controller名称统一使用分组名称
 */
class HomeController extends Controller {

	/* 空操作，用于输出404页面 */
	public function _empty(){
		$this->redirect('Index/index');
	}


    protected function _initialize(){
        /* 读取站点配置 */
        $config = api('Config/lists');
        C($config); //添加配置

        if(!C('WEB_SITE_CLOSE')){
            $this->error(L('web_site_close'));
        }

        if(defined('LANG_THEME') ){
            //$this->theme(LANG_THEME);
        }
        $ment = M('Channel')->where(array('pid'=>43,'status'=>1))->order('sort asc')->select();
        $fuliao = M('Channel')->where(array('pid'=>52,'status'=>1))->order('sort asc')->select();
        $jingtan = M('Channel')->where(array('pid'=>58,'status'=>1))->order('sort asc')->select();
        $tian = M('Channel')->where(array('pid'=>63,'status'=>1))->order('sort asc')->select();
        $di = M('Channel')->where(array('pid'=>67,'status'=>1))->order('sort asc')->select();
        $pao = M('Channel')->where(array('pid'=>71,'status'=>1))->order('sort asc')->select();
        $cust = M('Channel')->where(array('pid'=>75,'status'=>1))->order('sort asc')->select();
        $box = M('Channel')->where(array('pid'=>81,'status'=>1))->order('sort asc')->select();
        $jiuhe = M('Channel')->where(array('pid'=>87,'status'=>1))->order('sort asc')->select();
        $boli = M('Channel')->where(array('pid'=>94,'status'=>1))->order('sort asc')->select();
        $tao  = M('Channel')->where(array('pid'=>102,'status'=>1))->order('sort asc')->select();
        $tanz  = M('Channel')->where(array('pid'=>57,'status'=>1))->order('sort asc')->select();
        $this->assign('tanz',$tanz);
        $this->assign('ment',$ment);
        $this->assign('fuliao',$fuliao);
        $this->assign('jingtan',$jingtan);
        $this->assign('tian',$tian);
        $this->assign('di',$di);
        $this->assign('pao',$pao);
        $this->assign('cust',$cust);
        $this->assign('box',$box);
        $this->assign('jiuhe',$jiuhe);
        $this->assign('boli',$boli);
        $this->assign('tao',$tao);

        if(isMobile() || is_weixin()){
            $this->theme('mobile');
        }
    }

	/* 用户登录检测 */
	protected function login(){
		/* 用户登录检测 */
		is_login() || $this->error(L('un_login'), U('User/login'));
	}

}
